<?php

include_once "xAP-functions/webincludes.php";
include_once "Weather/Timer.php";

$id=intval($_POST["id"]);
$delete=intval($_POST["delete"]);

echo webpageheader();

if ($delete==1){
	/*
	dbexec("delete xap_news_story_tag.* FROM xap_news_story_tag
inner join xap_news_story on xap_news_story_tag.storyid=xap_news_story.storyid
where xap_news_story.sourceid=".$id);
	dbexec("delete from xap_news_story where SourceID=".$id);
	dbexec("delete from xap_news_source where SourceID=".$id);
	*/
}
else
{


		if($id==0){
			$sql="insert into xAP_Pictures_Source (Alias,Location,MonitorLocation,SourceType,Active) VALUES (
			'".dbesc($_POST["Alias"])."',
			'".dbesc($_POST["Location"])."',
			'".dbesc($_POST["MonitorLocation"])."',
			'".intval($_POST["SourceType"])."',
			1
			)";
		}else{
			$sql="update xAP_Pictures_Source set 
			Alias='".dbesc($_POST["Alias"])."',
			Location='".dbesc($_POST["Location"])."',
			MonitorLocation='".dbesc($_POST["MonitorLocation"])."',
			SourceType=".intval($_POST["SourceType"])."
			where SourceID=".$id;
		
		}
		dbexec($sql);
		//echo $sql;
		//WeatherImport($id);
		
		

		
}


//header("Location:config_setup.php");
//

echo "<script>
window.location ='config_setup.php';
</script>";


echo webpagefooter();
?>